# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=4
PYTHON_DEPEND="3:3.1"
inherit scons-utils toolchain-funcs multilib

MY_PV="cb6e89af8012"
MY_P="${PN}-${MY_PV}"

SRC_URI="https://www.mitsuba-renderer.org/hg/mitsuba/archive/${MY_PV}.tar.bz2"

DESCRIPTION="Mitsuba physically based renderer"
HOMEPAGE="https://www.mitsuba-renderer.org"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

RDEPEND="virtual/jpeg
        media-libs/libpng
	x11-libs/libX11
	media-libs/glew
	x11-libs/qt-core
	x11-libs/qt-gui
	x11-libs/qt-opengl
	media-libs/openexr
	dev-libs/xerces-c
	dev-libs/boost
	media-libs/collada-dom"
DEPEND="dev-util/scons
	${RDEPEND}"
S=${WORKDIR}/${MY_P}

src_prepare() {
	mkdir -p "${S}/dependencies"
	echo "${PV}" > "${S}/dependencies/version"
}

src_configure() {
	ln -s "${S}/build/config-linux.py" "${S}/config.py"
}

src_compile() {
	tc-export CC CXX
	escons || die "Scons failed"
}

src_install() {
	cd dist
	
	exeinto /usr/bin
	doexe mitsuba mtssrv mtsgui mtsutil mtsimport || die
	dolib.so libmitsuba-hw.so libmitsuba-render.so libmitsuba-core.so libmitsuba-bidir.so || die
	
	insinto "/usr/share/${PN}"
	doins -r "${S}/data/ior"
	doins -r "${S}/data/schema"

	exeinto "/usr/share/${PN}/plugins"
	doexe plugins/*.so

	exeinto "/usr/share/${PN}/python"
	doexe python/*.so

# 	local my_plugins="/usr/$(get_libdir)/${PN}/plugins"
# 	into ${my_plugins}
# 	dolib.so plugins/*.so || die
# 
# 	local my_python="/usr/$(get_libdir)/${PN}/python"
# 	into ${my_python}
# 	dolib.so python/*.so || die
}
